package org.itboys.mobile.controller.weixin.product;

import org.itboys.commons.utils.tools.LongUtil;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.mobile.dto.member.SundayWeixinMemberDto;
import org.itboys.mobile.dto.product.SundayProductDto;
import org.itboys.mobile.entity.mysql.product.SundayProduct;
import org.itboys.mobile.service.mysql.weixin.product.SundayWeiXinProductService;
import org.itboys.mobile.util.HttpRequestUtil;
import org.itboys.mobile.util.MemberUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

/**
 * 作者：zzq
 * 时间：2017/12/1
 * 描述：迈迪龙_微信_产品
 */
@Controller
@RequestMapping("/sunday/weixin/product")
public class SundayWeixinProductController extends BaseController{
    @Autowired
    private SundayWeiXinProductService productService;

    @RequestMapping("/findOne")
    public String findOne(
            HttpServletRequest request,
            @RequestParam(value = "id", required = true)Long  id,
            Model model){
        //获取session中的用户信息
        SundayWeixinMemberDto member = MemberUtil.getUser(request);
        if(LongUtil.isZreo(member.getRecommendId())){
            return "/newcoo/weixin/doLogin";
        }
        SundayProduct product=productService.findOne(id);
        model.addAttribute("product",product);
        return "/newcoo/weixin/product/findOne";
    }


}
